// pages/wechatD/wechatD.js
const utils = require('../../utils/util.js');
const post = utils.post;
const getCurrentPageUrlWithArgs = utils.getCurrentPageUrlWithArgs;
Page({

    /**
     * 页面的初始数据
     */
    data: {

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        let that = this;
        that.erweima()
    },
    erweima() {
        let that = this;
        let uid = wx.getStorageSync('z_uid');
        let p = {
            m: 'get_kefu',
            uid: uid
        }
        post(p).then(res => {
            that.setData({
                kf_img: res.list.kf_img,
                kf_wx: res.list.kf_wx
            })
        })
    },
    submitFormId(e) {
        let formId = e.detail.formId;
        let button = e.detail.target.dataset.name;
        var m_uid = wx.getStorageSync("m_uid");
        let page = getCurrentPageUrlWithArgs();
        let p = {
            m: 'colform',
            uid: m_uid,
            openid: wx.getStorageSync('weapp_openid'),
            formId: formId,
        }
        if (page && page.length > 0) {
            p.page = page;
        }
        if (button && button.length > 0) {
            p.button = button;
        }
        //console.log(p);
        post(p).then(res => {})
    },
    copyWxh: function() {
        var that = this;
        wx.setClipboardData({
            data: that.data.kf_wx,
            success: function(res) {}
        });

    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    }
})